
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div id="root"></div>
    
</body>
<script>

    // 单向数据流：子组件可以使用父组件传递过来的数据，但是不能修改传递过来的数据
    const app = Vue.createApp({
        components: {
        },
        data(){
            return {
              content: 'what`s the happen?',
              count: 100,
              params:{
                  greet: "hello",
                  num: 1000
              }
            }
        },
        methods:{
            
        },
        template:
        `
            <div>
                <test v-bind="params" :data-content="content" :count="count"/>
            </div>
        `
    });

    app.component('test', {
        props: {
            dataContent:{
                type: String
            },
            greet:{
                type: String
            },
            num:{
                type: Number
            },
            count:{
                type: Number
            }
        },
        data(){
            return {
                myCount: this.num
            }
        },
        methods: {
           
        },
        template: 
        `
            <div>{{dataContent}}</div>
            <div>{{greet}} == {{num}}</div>
            <div style="background:black;color:white;">
                <p>计数器:::{{myCount}}</p>
                <p><Button @click="myCount++">点击</Button></p>
            </div>
        `
    });

    const vm = app.mount("#root");
</script>
</html>